<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('撤销订单记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                          <!--  <li>
                                <label>定单id：</label>
                                <select name="ordersId">
                                    <option value="">所有</option>
                                    <option value="-1">代码生成请选择字典属性</option>
                                </select>
                            </li>-->
                            <li>
                                <label>订单编号：</label>
                                <input type="text" name="ordersNumber"/>
                            </li>
                            <!--<li>
                                <label>接单人id：</label>
                                <select name="userId">
                                    <option value="">所有</option>
                                    <option value="-1">代码生成请选择字典属性</option>
                                </select>
                            </li>-->
                            <li>
                                <label>审核状态：</label>
                                <select name="type" th:with="type=${@dict.getType('dl_orders_cxlog_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success multiple disabled" onclick="verifyByIds('通过',1)" shiro:hasPermission="dl:cxlog:edit">
                    <i class="fa fa-edit"></i>通过
                </a>
                <a class="btn btn-danger btn-xs multiple disabled" onclick="verifyByIds('驳回',2)" shiro:hasPermission="dl:cxlog:edit">
                    <i class="fa fa-edit"></i> 驳回
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="dl:cxlog:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dl:cxlog:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dl:cxlog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dl:cxlog:remove')}]];
        var typeDatas = [[${@dict.getType('dl_orders_cxlog_type')}]];
        var prefix = ctx + "dl/cxlog";
        var options='';
        $(function() {
            options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "撤销订单记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'dlUser.wxName',
                    title: '接单人微信昵称'
                },
                {
                    field: 'ordersNumber',
                    title: '订单编号'
                },
                {
                    field: 'type',
                    title: '审核状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '撤销理由'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if (row.type==0) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="verifyById(\'' + row.id+"\',\'1" + '\')"><i class="fa fa-university"></i>通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="verifyById(\'' + row.id+"\',\'2" + '\')"><i class="fa fa-remove"></i>驳回</a> ');
                        }
                        if(row.type!=0){
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function verifyById(id,flag) {

            console.log(id)
            $.modal.confirm("确定通过该条" + table.options.modalName + "信息吗？", function() {
                var data = {ids:id,flag:flag};
                 $.operate.submit(prefix+"/updateshDlOrdersCxlogByIds", "post", "json", data);
            })
        }
        function verifyByIds(a,b) {
            	table.set();
            	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            	if (rows.length == 0) {
            	    $.modal.alertWarning("请至少选择一条记录");
            	    return;
            	}
            	$.modal.confirm("确认要"+a+"选中的" + rows.length + "条数据吗?", function() {
            	   var data = {ids: rows.join(),flag:b};
                 $.operate.submit(prefix+"/updateshDlOrdersCxlogByIds", "post", "json", data);
            	});
            }

    </script>
</body>
</html>